import {create} from "../../src/storx";
import * as React from "react";

class CountStore {
   @state count: number = 0
   @state text = 'Hello';
   @state private _test = 'test'
   @state user={
      $name: 'John',
      age: 30
   }

   changeUser(){
      console.log('changeUser')
      this.user.$name = this.user.$name + '2'
   }

   get test() {
      console.log('get test',this['#test2'])

      return this._test
   }
   set  test(value) {
      console.log('set test', value)
      this._test = value
   }

   increment() {
      this.count++
   }

   updateText() {
      this.text = this.text + ' World'
   }

   @initialize increment3() {
      console.log('increment 5');
   }

   @builder TestBuilder(){
      console.log("=========================count  ===================")
      console.log('TestBuilder render');
      return <div>
         <div>{this.test}</div>
         <button onClick={this.increment}>TestBuilder: {this.count}</button>
      </div>
   }
}
// useCountStore({scope: 'local'})
export const useCountStore = create(CountStore)
